﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using FirmaTransportowa.Presenters;

namespace FirmaTransportowa
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                SqlConnection conn = SqlConnectionFactory.getConnection();
                conn.Open();
                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("Nie można połączyć z bazą. Sprawdź swój connection string w pliku FirmaTransportowa.exe.config.\n\nAktualny connection string to:\n" +
                    ConfigurationManager.ConnectionStrings["TransportConnectionString"].ToString(),"Błąd połączenia",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }

            InitializationService initializationService = new InitializationService();
            initializationService.init();

            LoginPresenter loginPresenter = new LoginPresenter();
            Application.Run(loginPresenter.getView());
        }
    }
}